<!-- no need for thumnails unless there is more then one image -->
<% if product.images.size > 1 %>
  <ul id="product-thumbnails" class="thumbnails inline" data-hook>
    <% product.images.each do |i| %>
      <li class="tmb-all" id="tmb-<%= i.id.to_s %>"><%= link_to image_tag(i.attachment.url(:mini)), i.attachment.url(:product) %></li>
    <% end %>
    <% if product.has_variants?
      variants.each do |v|
        if v.available?
          v.images.each do |i| %>
            <li class="vtmb-<%= v.id.to_s %> vtmb" id="tmb-<%= i.id.to_s %>"><%= link_to image_tag(i.attachment.url(:mini)), i.attachment.url(:product) %></li>
          <%
          end
        end
      end
    end
    %>
  </ul>
<% end %>

<% if product.has_variants?
  has_checked = false %>
  <h4 id="variant-images" class="image_for">
  </h4>
  <ul id="variant-thumbnails" class="thumbnails add_images">
    <% variants.each do |v|
        checked = !has_checked && (v.available?)
        has_checked = true if checked

        if checked
          v.images.each do |i| %>
            <li><%= link_to(image_tag(i.attachment.url(:mini)), i.attachment.url(:product)) %></li>
          <% end %>
        <% end %>
      <% end %>
    </ul>
<% end %>

<% content_for :head do %>
  <script type="text/javascript" charset="utf-8">
    var images = new Array();
    <% variants.each do |v| %>
      images[<%= v.id.to_s %>] = new Array();
      <% v.images.each_with_index do |image, i| %>
        images[<%= v.id.to_s %>][<%= i %>] = <%== link_to(image_tag(image.attachment.url(:mini)), image.attachment.url(:product)).to_json %>;
      <% end %>
    <% end %>
  </script>
<% end %>
 <!--<script src="/assets/product.js?1334756824" type="text/javascript"></script>-->
